#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

/*
len = length(t)
f[i][j][0/1]代表匹配到第i个数，删除j次
f[i][j]][1] 代表s[i - len + 1, i] == t
f[i][j][0] 代表不匹配   
且此时前i个都不包含t

if(v[i] == 0) // 不匹配
f[i][j][0] = f[i - 1][j][0] + f[i - 1][j][1];
f[i][j][1] = 0;

if(v[i] == 1) // 匹配
f[i][j][1] = f[i - 1][j - 1][0] + f[i - 1][j - 1][1];
f[i][j][0] = f[i - k][j][0] + f[i - k][j][1]
*/

using namespace std;
using LL = long long;
const int N = 510, mod = 1e9 + 7;

int n, m;
char s[N], t[N];
int v[N];
int dp[N][N][2];

bool check(int k){
    for(int i = k - m + 1, j = 1; i <= k; i ++, j ++ ){
        if(s[i] != t[j]) return false;
    }
    return true;
}


void solve()
{
    scanf("%s%s", s + 1, t + 1);
    n = strlen(s + 1),  m = strlen(t + 1);

    if(n < m) 
    {
        cout << 0 << " " << 1 << endl;
        return ;
    }
    
    memset(dp, 0, sizeof dp), memset(v, 0, sizeof v);
    

    for(int i = m; i <= n; i ++){
        if(check(i)) v[i] = 1;
    }

    dp[0][0][0] = 1;


    for(int i = 1; i <= n; i ++){
        for(int j = 0; j <= i; j ++){
            if(!v[i]){
                dp[i][j][0] = ((LL)dp[i - 1][j][0] + dp[i - 1][j][1]) % mod;
            }else{
                if(j && i - m >= 0){
                    dp[i][j][1] = ((LL)dp[i - m][j - 1][0] + dp[i - m][j - 1][1]) % mod;
                }
                    for(int k = max(i - m + 1, 0); k < i; k ++){
                        dp[i][j][0] = ((LL)dp[k][j][1] + dp[i][j][0]) % mod;
                    }
                
            }
        }
    }


    for(int i = 0; i <= n; i ++){
        int res = (dp[n][i][0] + dp[n][i][1]) % mod;
        if(res > 0){
            printf("%d %d\n", i, res);
            return;
        }
    }
    return;
}






int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);

    int T;
    scanf("%d", &T);
    while(T--){
        solve();
    }

    return 0;
}